/**
*	Gives a lexicographic order.
*	
*	@param post1 - post-it to be compared
*	@param post2 - post-it to be compared
*	@return int - negative if post1 preceds post2 and positive if otherwise. 0 says that they have equivalent relevance.
*/
function COMPARE_BY_TASK(post1, post2){
	return post1.getTask().localeCompare(post2.getTask());
}

/**
*	Gives a decrescent order by the number of stars.
*	
*	@param post1 - post-it to be compared
*	@param post2 - post-it to be compared
*	@return int - negative if post1 preceds post2 and positive if otherwise. 0 says that they have equivalent relevance.
*/
function COMPARE_BY_STARS(post1, post2){
	var stars1 = post1.getStars();
	var stars2 = post2.getStars();
	if(stars1 < stars2)
		return 1;
	else if(stars1 > stars2)
		return -1;
	else
		return COMPARE_BY_TASK(post1,post2);
}

/**
*	Gives a chronological order by expiring dates.
*	
*	@param post1 - post-it to be compared
*	@param post2 - post-it to be compared
*	@return int - negative if post1 preceds post2 and positive if otherwise. 0 says that they have equivalent relevance.
*/
function COMPARE_BY_EXPIRING_DATE(post1, post2){
	if(typeof post2.getExpirationDate() == "undefined")
		return -1;
	else if(typeof post1.getExpirationDate() == "undefined")
		return 1;
	else
		return post1.getExpirationDate().valueOf().toString().localeCompare(post2.getExpirationDate().valueOf().toString());
}

/**
*	Gives a chronological order by finalization dates.
*	
*	@param post1 - post-it to be compared
*	@param post2 - post-it to be compared
*	@return int - negative if post1 preceds post2 and positive if otherwise. 0 says that they have equivalent relevance.
*/
function COMPARE_BY_FINALIZATION_DATE(post1, post2){

	if(typeof post2.getExpirationDate() == "undefined")
		return -1;
	else if(typeof post1.getExpirationDate() == "undefined")
		return 1;
	else
		return post1.getFinalizationDate().valueOf().toString().localeCompare(post2.getFinalizationDate().valueOf().toString());	
}


